<template>
    <div style="width: 70%">
    <div style="margin-bottom: 30px">编辑用户</div>
    <el-form :inline="true" :model="form"  label-width="120px">
        <el-form-item label="会员卡号">
            <el-input v-model="form.username" disabled></el-input>
        </el-form-item>
        <el-form-item label="姓名">
            <el-input v-model="form.name" placeholder="请输入姓名"></el-input>
        </el-form-item>
        <el-form-item label="年龄">
            <el-input v-model="form.age" placeholder="请输入年龄"></el-input>
        </el-form-item>
        <el-form-item label="性别">
            <el-input v-model="form.sex" placeholder="请输入性别"></el-input>
        </el-form-item>
        <el-form-item label="联系方式">
            <el-input v-model="form.phone" placeholder="请输入联系方式"></el-input>
        </el-form-item>
        <el-form-item label="地址">
            <el-input v-model="form.address" placeholder="请输入地址"></el-input>
        </el-form-item>

    </el-form>
        <div style="text-align: center  ;margin-top:5px ">
            <el-button type="primary" @click="update" size="medium">提交</el-button>
            <el-button type="info" @click="$router.push('/userList')" size="medium">返回</el-button>
        </div>
    </div>
</template>

<script>
    import request from "@/util/request";

    export default {
        name: "EditUser",
        data() {
            return {
                form:{}
            }
        },
        created() {
            const id=this.$route.query.id
            request.get('/user/'+id).then(res=>{
                this.form=res.data;
            })
        },
        methods:{
            update(){
                request.put('/user/update',this.form).then(res=>{
                    if(res.code=="200"){
                        this.$notify.success("修改成功")
                        this.$router.push("/userList")
                    }else{
                        this.$notify.error(res.msg)
                    }
                })
            }
        }
    }
</script>


